//
//  LTabBarViewController.m
//  UI09_UITabBar
//
//  Created by Lawliet on 15/12/30.
//  Copyright © 2015年 lanou.com. All rights reserved.
//

#import "LTabBarViewController.h"
#import "MineViewController.h"
#import "ShoppingCartViewController.h"
#import "ClassifyViewController.h"
#import "HomeViewController.h"
#import "ListViewController.h"
#import "GoodsViewController.h"

@interface LTabBarViewController ()

@end

@implementation LTabBarViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    /*
    // 全局修改UITabBar
    [[UITabBar appearance] setTintColor:[UIColor redColor]];
    [[UITabBar appearance] setBarTintColor:[UIColor blackColor]];

    // 全局修改UINavigationBar
    [[UINavigationBar appearance] setTintColor:[UIColor yellowColor]];
    [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
    
    */
    [self creatTabBar];
}
- (void)creatTabBar{
    ShoppingCartViewController *cinema = [[ShoppingCartViewController alloc] init];
    ClassifyViewController *find = [[ClassifyViewController alloc] init];
    
    MineViewController *mine = [[MineViewController alloc] init];
    HomeViewController *active = [[HomeViewController alloc] init];
    
    [self addChild:active title:@"首页" image:@"tab_but_home" imageSele:@"tab_but_home_pre"];
    [self addChild:find title:@"分类" image:@"tab_but_class" imageSele:@"tab_but_class_pre"];
    [self addChild:cinema title:@"购物车" image:@"tab_but_shopping" imageSele:@"tab_but_shopping_pre"];
    [self addChild:mine title:@"我的" image:@"tab_but_mine" imageSele:@"tab_but_mine_pre"];

    
//    FiveViewController *five = [[FiveViewController alloc] init];
//
//    SixViewController *six = [[SixViewController alloc] init];
//    
//    [self addChild:five title:@"第五" image:@"chat2" imageSele:@"chat2"];
//    
//    [self addChild:six title:@"第六" image:@"chat2" imageSele:@"chat2"];
}

// 自定义tabBar.m中的封装方法
- (void)addChild:(UIViewController *)childVC
            title:(NSString *)title
            image:(NSString *)image
        imageSele:(NSString *)imageSele

{
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childVC];
    childVC.title = title;
    childVC.view.backgroundColor = [UIColor whiteColor];
    childVC.tabBarItem.image =
        [UIImage imageNamed:image];
    childVC.tabBarItem.selectedImage =
    [[UIImage imageNamed:imageSele] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 取消tabbar文字渲染效果,属性字符串
    NSMutableDictionary *dicTemp = [NSMutableDictionary dictionary];
    dicTemp[NSForegroundColorAttributeName]
    = [UIColor blackColor];
    NSMutableDictionary *dicTempTwo =
    [NSMutableDictionary dictionary];
    dicTempTwo[NSForegroundColorAttributeName]=
    [UIColor redColor];
    [childVC.tabBarItem
     setTitleTextAttributes:dicTemp forState:UIControlStateNormal];
    [childVC.tabBarItem setTitleTextAttributes:dicTempTwo forState:
     UIControlStateSelected];
    [self addChildViewController:nav];
    
}
@end
